#—*—coding:utf-8 -*-
#@Time        :2022/7/16 16:19
#@Author      :dhx
#@File        :zujian_page.py
# @Software: PyCharm
from time import sleep

from selenium.webdriver.support.select import Select

from pages.base_pageage import BasePage
from selenium.webdriver.common.by import By
from selenium import webdriver
class ZuJian(BasePage):
    url='http://192.168.3.133/crm/index.php'
    zujian_locator = (By.ID, 'add')  # 添加组件
    zujian_name_locator = (By.ID, 'title')  # 名称
    leix_locator = (By.ID, 'widget')  # 类型
    save_locator = (By.CSS_SELECTOR, '#dialog-message > form > div:nth-child(4) > div > input.btn.btn-primary')#便签保存
    gonggao_locator = (By.XPATH, '//*[@id="widgets"]/div/div[2]/div/div[1]/a')#公告
    add_task_locator = (By.CSS_SELECTOR, '#calendar > div.c-event-grid > div.c-task-body > div.data-head > a > i')#任务


    def add_zujian(self):
        """点击添加组件"""
        self.driver.find_element(*self.zujian_locator).click()
        sleep(1)
    def input_zujian(self):
        """输入组件名"""
        self.driver.find_element(*self.zujian_name_locator).send_keys("组件")
        sleep(1)
    def option_zujian(self,first):
        """选择组件"""

        self.leixing = self.driver.find_element(*self.leix_locator)
        select = Select(self.leixing)
        select.select_by_index(first)
        sleep(2)


    def save_zujian(self):
        """保存"""
        self.driver.find_element(*self.save_locator).click()
        sleep(1)
    def gonggao(self):
        """"""
        self.driver.find_element(*self.gonggao_locator).click()
        sleep(1)

    def renwu(self):
        """点击添加任务"""
        self.driver.find_element(*self.add_task_locator).click()
        sleep(1)







